Skip to content

feat: change public schema to trueforge schema for Postgres - #488

Merged
thesujai merged 6 commits into
mainfrom
feat/update-schema-trueforge
Aug 31, 2026
Merged

feat: change public schema to trueforge schema for Postgres#488
thesujai merged 6 commits into
mainfrom
feat/update-schema-trueforge

Conversation

@thesujai

@thesujai thesujai commented Aug 28, 2026

Copy link
Copy Markdown
Contributor

Summary

change public schema to trueforge schema for Postgres

Changes

change public schema to trueforge schema for Postgres

How was this tested?

Recreating every scenarios and also through tests

Checklist

  • I have read the contributing guidelines
  • pnpm build, pnpm test, pnpm typecheck, pnpm lint:ci, and pnpm format:check pass locally
  • Tests added/updated where it makes sense
  • No hand-edits to generated code (packages/trueforge-sdk, .github/fern/openapi/openapi.json, docs/openapi.json) — fork PRs omit SDK regen; maintainers regenerate after merge
  • Docs / .env.example updated if configuration or behavior changed

Note

Medium Risk
One-time DDL that relocates live tables from public can fail or contend on locks in shared Postgres instances; bootstrap is guarded but upgrades should be validated on representative data.

Overview
Moves Trueforge’s Postgres footprint out of public into a dedicated trueforge schema so app data and Kysely’s migration tables are namespaced separately from other database users.

ensureTrueforgeSchema runs before migrations: on first use it creates the schema (with advisory lock + lock_timeout), then ALTER TABLE … SET SCHEMA for Kysely bookkeeping and all listed app tables still in public. Fresh installs and already-migrated DBs short-circuit when the namespace exists. The migrator now records history in migrationTableSchema: trueforge, and createDb sets search_path=trueforge on every pooled connection so unqualified queries hit the right tables.

AGENTS guidance and the Postgres client integration test are updated to assert search_path alongside existing timeout settings.

Reviewed by Cursor Bugbot for commit 43bf3cf. Bugbot is set up for automated code reviews on this repo. Configure here.

@changeset-bot

changeset-bot Bot commented Aug 28, 2026

Copy link
Copy Markdown

🦋 Changeset detected

Latest commit: 43bf3cf

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@truefoundry/trueforge Minor

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

@thesujai thesujai changed the title feat: feat: change public schema to trueforge schema for Postgres Aug 28, 2026
Comment thread packages/trueforge/src/db/postgres/schema.ts
Comment thread packages/trueforge/src/db/postgres/client.ts
Comment thread packages/trueforge/src/db/postgres/schema.ts Outdated
Comment thread packages/trueforge/src/db/postgres/schema.ts
Comment thread packages/trueforge/src/db/migratePostgres.ts
Comment thread packages/trueforge/tests/db/postgres/schemaBootstrap.test.ts Outdated
Comment thread packages/trueforge/src/db/postgres/schema.ts Outdated

@chiragjn chiragjn left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Keeping this approved. See if we really need the test

it('moves legacy public tables into trueforge and preserves migration history'

to run in C/I everytime

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using default effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Want higher recall? High effort reviews run extra passes and find more bugs. A team admin can switch effort levels in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 3263417. Configure here.

Comment thread packages/trueforge/src/db/postgres/schema.ts Outdated
@thesujai
thesujai enabled auto-merge (squash) August 31, 2026 11:31
@thesujai
thesujai merged commit 2025cef into main Aug 31, 2026
9 checks passed
@thesujai
thesujai deleted the feat/update-schema-trueforge branch August 31, 2026 11:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants